home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 125
/
Freelog_MarsAvril2015_No125.iso
/
Musique
/
Quod Libet
/
quodlibet-3.3.0-installer.exe
/
bin
/
quodlibet
/
qltk
/
menubutton.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2014-12-31
|
3KB
|
76 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
from gi.repository import Gtk, Gdk
from quodlibet import qltk
class MenuButton(Gtk.ToggleButton):
__menu = None
__menu_sig = None
def __init__(self, widget = None, arrow = False, down = True):
super(MenuButton, self).__init__()
bbox = Gtk.HBox(spacing = 3)
if widget:
bbox.pack_start(widget, True, True, 0)
if arrow:
arrow_type = Gtk.ArrowType.DOWN if down else Gtk.ArrowType.UP
bbox.pack_start(Gtk.Arrow.new(arrow_type, Gtk.ShadowType.IN), True, True, 0)
self._down = down
self.add(bbox)
self.connect('toggled', self._MenuButton__toggled_cb)
self.connect('button-press-event', self._MenuButton__press_cb)
self.connect('destroy', self._MenuButton__destroy)
def get_menu(self):
return self._MenuButton__menu
def set_menu(self, menu):
if self._MenuButton__menu:
self._MenuButton__menu.detach()
self._MenuButton__menu.disconnect(self._MenuButton__menu_sig)
self._MenuButton__menu = menu
menu.attach_to_widget(self, None)
self._MenuButton__menu_sig = menu.connect('deactivate', self._MenuButton__menu_deactivate_cb, self)
def __destroy(self, *args):
if self._MenuButton__menu:
self._MenuButton__menu.detach()
self._MenuButton__menu.disconnect(self._MenuButton__menu_sig)
self._MenuButton__menu = None
def __menu_deactivate_cb(self, menu, button):
button.set_active(False)
def __press_cb(self, widget, event):
if self._MenuButton__menu and event.button == Gdk.BUTTON_PRIMARY:
widget.set_active(True)
return True
def _popup(self):
event = Gtk.get_current_event()
(ok, button) = event.get_button()
if not ok:
button = Gdk.BUTTON_PRIMARY
time = event.get_time()
if self._down:
qltk.popup_menu_under_widget(self._MenuButton__menu, self, button, time)
else:
qltk.popup_menu_above_widget(self._MenuButton__menu, self, button, time)
def __toggled_cb(self, widget):
menu = self._MenuButton__menu
if widget.get_active() and menu:
self._popup()
elif menu:
menu.popdown()